home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: fscanf problem
- Date: 19 Mar 1996 19:51:44 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4in38g$9rt@news.xs4all.nl>
- References: <1996Mar19.184044@omega.ntu.ac.sg>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- sg7248613@omega.ntu.ac.sg writes:
-
- >I have been trying to read a section of data from a file for days.
-
- >The data segment goes like this:
- > .....
- > Patch norm0 4 { { 0 -1 0 } { 0 -1 0 } { 0 -1 0 } { 0 -1 0 } }
- > Patch vert0 4 { { 0 1 0 } { 1 1 0 } { 1 1 1 } { 0 1 1 } }.
- ^^
- what's that period doing there?
-
- > .....
- >My actual code segment is as follows:
-
- >fscanf(meshf, " Patch %s %d { { %f %f %f } { %f %f %f } { %f %f %f }\
- > { %f %f %f } }\n Patch %s %d { { %f %f %f } { %f %f %f }\
- > { %f %f %f } { %f %f %f } }\n", pptr->nname, &(pptr->numVert),
- > &tmpf[0], &tmpf[1], &tmpf[2], &tmpf[3], &tmpf[4], &tmpf[5],
- > &tmpf[6], &tmpf[7], &tmpf[8], &tmpf[9], &tmpf[10], &tmpf[11],
- > pptr->vname, &tmpi,
- > &tmpg[0], &tmpg[1], &tmpg[2], &tmpg[3], &tmpg[4], &tmpg[5],
- > &tmpg[6], &tmpg[7], &tmpg[8], &tmpg[9], &tmpg[10], &tmpg[11]);
-
- >The read of the first line is OK. But I can't scanf the second line
- >successfully. Could anyone please enlighten me on this? Thank you!
-
- What value is returned by fscanf()? That's a useful diagnositc.
-
- First, remove the \n in your control string -- that shouldn't
- be there. If you want to be sure only one line is read, then
- fgets() the line first, and then sscanf() on your line buffer.
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-